Repository navigation
fix: bound feature-mode inputs, clean allocation errors, record contract (0.4.0 prep) - #14
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Findings from an external beta test of
dinov2-cli(main at ce9429b):Abort trap 6. Feature preprocessing preserved native resolution with no bound; attention memory is quadratic in tokens.ggml_gallocr_alloc_graph/ backend buffer alloc return values were unchecked, so OOM aborted instead of erroring.AutoImageProcessoryields 256 tokens (224 crop) while the CLI produced 1444, causing cosine deltas ~0.046 and a rank flip. A preprocessing-grid mismatch, not numerical error.patcheshad no grid dimensions in the record; JSONL carried no per-image identity/order contract; D2EMB lacked grid dims.dinov2-cli 0.3.0for the 0.4.0 beta.Changes
--preprocess bounded): shortest edge > 518 resizes to 518 preserving aspect, then true-ceil alignment to patch multiples in a single bicubic resample.hfmode replicates the HF recipe (shortest edge 256 + center crop 224);crop518gives a fixed 37x37 grid for batching mixed aspect ratios.--no-resizeopts back to native resolution, still capped.--max-tokens N: hard cap on patch tokens (default4 * ceil(518/patch)^2= 5476 at patch 14, 0 disables), checked on prospective output dims before the expensive resize and before any graph construction. Exceeding it is a clean exit-1 error.ggml_gallocr_new, andggml_gallocr_alloc_graphfailures now print dims/token count with a--max-tokens/crop518hint and exit 1, freeing resources.index(0-based input order) andgrid {h, w}; record order equals input order;patchesdocumented as row-majorgrid.h * grid.w * hidden.grid_w/grid_hu32s.docs/superpowers/specs/2026-09-22-large-image-and-wrapper-ergonomics-design.md.Behavior changes
--no-resize); patch alignment is true-ceil, so already-aligned dims are unchanged (518 stays 518 -> 37 patches, previously 532/38).--no-resizeonly valid with--preprocess bounded;-crejects--preprocess/--no-resize.Verification
--dry-run --Werrorclean;git diff --checkclean.--preprocess hfvsfacebook/dinov2-small+AutoImageProcessordefaults on tench: 256 tokens both sides, cls cosine 0.996245, pooled cosine 0.996995 (residual = PIL antialiased bicubic vs Catmull-Rom, documented in docs/parity/README.md).--no-resizeexits 1 in ~0.2s with the cap error;crop518 --batch 2on 3440x5601 + 3440x4200 yields two records at grid 37x37 (index 0, 1).cls,topkarrays); only the newgrid/indexkeys were added.